大部份APP都會設計到個人化的應用,而Voice App在應用時,有時候也會有這個需求,而在Google Assistant上,要實現個人化的目標,目前有兩種做法:
本篇直接先用研究用 Google Sign-In來做看看
https://developers.google.com/actions/assistant/helpers#account_sign-in
https://github.com/actions-on-google/dialogflow-helper-intents-nodejs
const {SignIn} = require('actions-on-google');
module.exports = {
'ask_for_sign_in': (conv) => {
conv.ask(new SignIn());
},
'ask_for_sign_in_confirmation': (conv, params, signin) => {
if (signin.status !== 'OK') {
return conv.ask('You need to sign in before using the app.');
}
// const access = conv.user.access.token;
// possibly do something with access token
return conv.ask('Great! Thanks for signing in.');
},
};
取出 SignIn 這個Object 然後在詢問,看使用者有無同意。